<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: ActiveSupport::Multibyte::UnicodeDatabase</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">ActiveSupport::Multibyte::UnicodeDatabase</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/rails/activesupport/lib/active_support/multibyte/unicode_database_rb.html">
                vendor/rails/activesupport/lib/active_support/multibyte/unicode_database.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="../../Object.html">
                Object
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Holds static data from the Unicode database
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000314">===</a>&nbsp;&nbsp;
      <a href="#M000315">dirname</a>&nbsp;&nbsp;
      <a href="#M000316">filename</a>&nbsp;&nbsp;
      <a href="#M000313">load</a>&nbsp;&nbsp;
      <a href="#M000312">new</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">


    <div id="constants-list">
      <h3 class="section-bar">Constants</h3>

      <div class="name-list">
        <table summary="Constants">
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">ATTRIBUTES</td>
          <td>=</td>
          <td class="context-item-value">:codepoints, :composition_exclusion, :composition_map, :boundary, :cp1252</td>
        </tr>
        </table>
      </div>
    </div>



      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000315" class="method-detail">
        <a name="M000315"></a>

        <div class="method-heading">
          <a href="#M000315" class="method-signature">
          <span class="method-name">dirname</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the directory in which the data files are stored
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000315-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000315-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/multibyte/unicode_database.rb, line 59</span>
59:       <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">dirname</span>
60:         <span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-keyword kw">__FILE__</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">'/../values/'</span>
61:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000316" class="method-detail">
        <a name="M000316"></a>

        <div class="method-heading">
          <a href="#M000316" class="method-signature">
          <span class="method-name">filename</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the <a href="UnicodeDatabase.html#M000316">filename</a> for the
data file for this version
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000316-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000316-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/multibyte/unicode_database.rb, line 64</span>
64:       <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">filename</span>
65:         <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">dirname</span>, <span class="ruby-value str">&quot;unicode_tables.dat&quot;</span>)
66:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000312" class="method-detail">
        <a name="M000312"></a>

        <div class="method-heading">
          <a href="#M000312" class="method-signature">
          <span class="method-name">new</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000312-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000312-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/multibyte/unicode_database.rb, line 16</span>
16:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
17:         <span class="ruby-ivar">@codepoints</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Codepoint</span>.<span class="ruby-identifier">new</span>)
18:         <span class="ruby-ivar">@composition_exclusion</span> = []
19:         <span class="ruby-ivar">@composition_map</span> = {}
20:         <span class="ruby-ivar">@boundary</span> = {}
21:         <span class="ruby-ivar">@cp1252</span> = {}
22:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000314" class="method-detail">
        <a name="M000314"></a>

        <div class="method-heading">
          <a href="#M000314" class="method-signature">
          <span class="method-name">===</span><span class="method-args">(other)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000314-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000314-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/multibyte/unicode_database.rb, line 46</span>
46:             <span class="ruby-keyword kw">def</span> <span class="ruby-operator">===</span>(<span class="ruby-identifier">other</span>)
47:               <span class="ruby-identifier">detect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">other</span> } <span class="ruby-operator">?</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
48:             <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000313" class="method-detail">
        <a name="M000313"></a>

        <div class="method-heading">
          <a href="#M000313" class="method-signature">
          <span class="method-name">load</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Loads the Unicode database and returns all the internal objects of <a
href="UnicodeDatabase.html">UnicodeDatabase</a>.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000313-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000313-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/multibyte/unicode_database.rb, line 36</span>
36:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">load</span>
37:         <span class="ruby-keyword kw">begin</span>
38:           <span class="ruby-ivar">@codepoints</span>, <span class="ruby-ivar">@composition_exclusion</span>, <span class="ruby-ivar">@composition_map</span>, <span class="ruby-ivar">@boundary</span>, <span class="ruby-ivar">@cp1252</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">filename</span>, <span class="ruby-value str">'rb'</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-constant">Marshal</span>.<span class="ruby-identifier">load</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">read</span> }
39:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
40:             <span class="ruby-identifier">raise</span> <span class="ruby-constant">IOError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;Couldn't load the Unicode tables for UTF8Handler (#{e.message}), ActiveSupport::Multibyte is unusable&quot;</span>)
41:         <span class="ruby-keyword kw">end</span>
42: 
43:         <span class="ruby-comment cmt"># Redefine the === method so we can write shorter rules for grapheme cluster breaks</span>
44:         <span class="ruby-ivar">@boundary</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">_</span><span class="ruby-operator">|</span>
45:           <span class="ruby-ivar">@boundary</span>[<span class="ruby-identifier">k</span>].<span class="ruby-identifier">instance_eval</span> <span class="ruby-keyword kw">do</span>
46:             <span class="ruby-keyword kw">def</span> <span class="ruby-operator">===</span>(<span class="ruby-identifier">other</span>)
47:               <span class="ruby-identifier">detect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">other</span> } <span class="ruby-operator">?</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
48:             <span class="ruby-keyword kw">end</span>
49:           <span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@boundary</span>[<span class="ruby-identifier">k</span>].<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Array</span>)
50:         <span class="ruby-keyword kw">end</span>
51: 
52:         <span class="ruby-comment cmt"># define attr_reader methods for the instance variables</span>
53:         <span class="ruby-keyword kw">class</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword kw">self</span>
54:           <span class="ruby-identifier">attr_reader</span>(<span class="ruby-operator">*</span><span class="ruby-constant">ATTRIBUTES</span>)
55:         <span class="ruby-keyword kw">end</span>
56:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>